<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Session;

class Attention extends Controller
{
 	   public function index($buid)
 	   {


 	   	//新闻信息
 	   	$author = Db::name('article a')
 	   	->join('user_self u','u.uid = a.uid')
 	   	->where('a.uid = '.$buid)
 	   	->select();
 	   	//是否关注
 	   	if (session('uid','','think')) {  
        $att = Db::name('follow f')
        ->where('f.uid ='.session('uid','','think'))
       ->field('buid')
       ->select();
            $att2 = array();
            foreach ($att as $key => $v) {
                $att2[] = $v['buid'];
            }
            
                $att3 = null;
                foreach ($att2 as $key => $value) {
                    $att3 .= $value.',';
            }
        } else {
           $att3 = null;
        }

 	   	// var_dump($author);die;
 	   	//栏目条
 	   	 if (session('uid','','think')) {  
        $ass = Db::name('subscribe s')
        ->join('column c','s.cid = c.cid')
        ->where('s.uid ='.session('uid','','think'))
        ->order('id desc')
        ->limit(10)
        ->select();
            
        } else {
           $ass = null;
        }
        //登录栏目条
        if (session('uid','','think')) {  
        $assz = Db::name('subscribe s')
        ->join('column c','s.cid = c.cid')
        ->where('s.uid ='.session('uid','','think'))
        ->select();
            
        } else {
           $assz = null;
        }
        //未登录栏目
        $hotss = Db::name('column')
        ->where('pid > 0 and hot = 1')
        ->limit(9)
        ->select();
        //未登入下栏目
        $hotssz = Db::name('column')
        ->where('pid > 0 and hot = 1')
        ->limit(10)
        ->select();
        //作者信息
        $writer = Db::name('user_self u')
        ->where('u.uid ='.$buid)
        ->select();
        // var_dump($writer);die;
        // var_dump($author);die;
 	   	return view('Attention/index',[
                'ass' => $ass,
 	   			'assz' => $assz,
 	   			'author' => $author,
 	   			'att3' => $att3,
 	   			'writer' => $writer,
                'hotss' => $hotss,
                'hotssz' => $hotssz,
 	   		]);
 	   }
}    